import {createStore} from 'vuex'
import {ref} from "vue";

export default createStore({
    state: {
        isupdata:false,
        isCollapse: false,//是否收缩侧边栏
        AEIsShow: false,//是否显示编辑/添加框
        systemUserArr: [{}],
        positionArr: [{}],
        departmentArr: [{}],
        positionForm: {
            dname: "",
            did: "",
            rid: "",
            rname: ""
        },
        departmentForm: {
            name: "",
            id: ""
        },
        editIndex: 0,//编辑的索引
    },
    getters: {},
    mutations: {
        setIsupData(state, data) {
            state.isupdata = data;
        },
        changeCollapse(state) {
            state.isCollapse = !state.isCollapse
        },
        setSystemUserArr(state, newArr) {
            state.systemUserArr = newArr
            //console.log("提交了systemUserArr" + JSON.stringify(state.systemUserArr))
        },
        setPositionArr(state, newArr) {
            state.positionArr = newArr
        },
        setShow(state, bool) { //设置编辑框是否显示
            console.log("提交了setShow" + bool)
            state.AEIsShow = bool
        },
        setDepartmentArr(state, newArr) {
            state.departmentArr = newArr
        },
        setPositionForm(state, form) {
            state.positionForm = form
        },
        setEditIndex(state, index) { //设置编辑的索引
            state.editIndex = index
        },
        setDepartmentForm(state, form) {
            state.departmentForm = form
        }
    },
    actions: {},
    modules: {}
})
